package Utils;

import android.content.Context;
import android.media.MediaPlayer;
import android.util.Log;
import android.widget.Toast;

import com.example.gift.MainActivity;
import com.example.gift.R;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

public class Play {
    private MediaPlayer mediaPlayer;

    protected Context context;

    public Play(MainActivity mainActivity) {
        context = mainActivity;
        init();
    }

    public void Play(Context context){
        this.context = context;
        init();
    }

    public void init(){
        Log.e("Play","Init()");
        mediaPlayer = MediaPlayer.create(context,R.raw.happy);
//        try {
//            mediaPlayer.prepare();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
        mediaPlayer.setLooping(true);
        Toast.makeText(context,"Play",Toast.LENGTH_LONG).show();
        mediaPlayer.start();
//        Timer t = new Timer();
//        TimerTask timerTask = new TimerTask() {
//            @Override
//            public void run() {
//                if (mediaPlayer == null) return;
//                if ()
//            }
//        };
    }
}
